home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gchess40.lha / gnuchess4.0p62 / src / nuxdsp.c < prev    next >
C/C++ Source or Header  |  1993-06-22  |  21KB  |  1,063 lines

  1. /*
  2.  * nuxdsp.c - (new)  ALPHA interface for CHESS
  3.  *
  4.  * Copyright (c) 1988,1989,1990 John Stanback
  5.  * Copyright (c) 1992 Free Software Foundation
  6.  *
  7.  * This file is part of GNU CHESS.
  8.  *
  9.  * GNU Chess is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2, or (at your option)
  12.  * any later version.
  13.  *
  14.  * GNU Chess is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with GNU Chess; see the file COPYING.  If not, write to
  21.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23. #include <ctype.h>
  24. #include <signal.h>
  25. #ifdef MSDOS
  26. #include <dos.h>
  27. /*#include <conio.h>*/
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <time.h>
  31.  
  32. #define ESC 0x1B
  33. #define refresh() fflush(stdout)
  34.  
  35. static void param (short n);
  36.  
  37. #else
  38. #include <sys/param.h>
  39. #include <sys/types.h>
  40. #include <sys/file.h>
  41. #include <curses.h>
  42.      extern short int sscore[];
  43.  
  44. #if defined(__STDC__)
  45. /* <stdlib.h> */
  46.      extern void *malloc (size_t);
  47.      extern void exit (int);
  48.  
  49. /* <string.h> */
  50.      extern char *strcat (char *, const char *);
  51.      extern int strcmp (const char *, const char *);
  52.      extern char *strcpy (char *, const char *);
  53.  
  54. /* <time.h> */
  55.      extern long int time (long int *);
  56. #endif
  57.  
  58. #endif /* MSDOS */
  59.  
  60. #include "gnuchess.h"
  61. int mycnt1, mycnt2;
  62.  
  63. extern short int pscore[2];
  64.  
  65. #define TAB (43)
  66. /* coordinates within a square for the following are ([1,5],[1,3]) */
  67. #define SQW (5)
  68. #define SQH (3)
  69. #define VIR_C(s)  ((flag.reverse) ? 7-column(s) : column(s))
  70. #define VIR_R(s)  ((flag.reverse) ? 7-row(s) : row(s))
  71. #define VSQ_X(x)  ((flag.reverse) ? SQW + 1 - (x) : (x))
  72. #define VSQ_Y(y)  ((flag.reverse) ? SQH + 1 - (y) : (y))
  73. #define Vblack(s) (!((VIR_C(s) + VIR_R(s)) % 2))
  74. /* Squares swapped */
  75. #define Vcoord(s,x,y) \
  76.     ((SQW)*(VIR_C(s)))+(x),((SQH)*(7-VIR_R(s))+(y))
  77. /* Squares and internal locations swapped */
  78. #define VcoordI(s,x,y) \
  79.     ((SQW)*(VIR_C(s)))+(VSQ_X(x)),((SQH)*(7-VIR_R(s))+(VSQ_Y(y)))
  80. /* Squares and internal rows swapped */
  81. #define VcoordR(s,x,y) \
  82.     ((SQW)*(VIR_C(s)))+(x),((SQH)*(7-VIR_R(s))+(VSQ_Y(y)))
  83. char Analysis[128] = "";
  84. unsigned short int MV[MAXDEPTH];
  85. int MSCORE;
  86. char *DRAW;
  87. extern char mvstr[4][6];
  88. extern short Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
  89. short PositionFlag = 0;
  90.  
  91. #if defined(MSDOS) && !defined(SEVENBIT)
  92. static void ONormal (void);
  93. static void OReverse (void);
  94.  
  95. #endif /* MSDOS && !SEVENBIT */
  96.  
  97. extern char *getenv (const char *);
  98. void TerminateSearch (int), Die (int);
  99.  
  100. void
  101. Initialize (void)
  102. {
  103.   signal (SIGINT, Die);
  104. #ifndef MSDOS
  105.   signal (SIGQUIT, Die);
  106.   initscr ();
  107.   crmode ();
  108. #else
  109.   mycnt1 = mycnt2 = 0;
  110. #endif /* MSDOS */
  111. }
  112.  
  113. void
  114. ExitChess (void)
  115. {
  116.   ListGame ();
  117.   gotoXY (1, 24);
  118. #ifndef MSDOS
  119.   refresh();
  120.   nocrmode ();
  121.   endwin ();
  122. #endif /* MSDOS */
  123.   exit (0);
  124. }
  125.  
  126. void
  127. Die (int Sig)
  128. {
  129.   char s[80];
  130.  
  131.   signal (SIGINT, SIG_IGN);
  132. #ifdef MSDOS
  133.   Sig++;            /* shut up the compiler */
  134. #else
  135.   signal (SIGQUIT, SIG_IGN);
  136. #endif /* MSDOS */
  137.   ShowMessage (CP[31]);        /*Abort?*/
  138.   scanz ("%s", s);
  139.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  140.     ExitChess ();
  141.   signal (SIGINT, Die);
  142. #ifndef MSDOS
  143.   signal (SIGQUIT, Die);
  144. #endif /* MSDOS */
  145. }
  146.  
  147. void
  148. TerminateSearch (int Sig)
  149. {
  150.   signal (SIGINT, SIG_IGN);
  151. #ifdef MSDOS
  152.   Sig++;            /* shut up the compiler */
  153. #else
  154.   signal (SIGQUIT, SIG_IGN);
  155. #endif /* MSDOS */
  156.   if (!flag.timeout)
  157.     flag.musttimeout = true;
  158.   flag.bothsides = false;
  159.   signal (SIGINT, Die);
  160. #ifndef MSDOS
  161.   signal (SIGQUIT, Die);
  162. #endif /* MSDOS */
  163. }
  164. void
  165. ShowLine (short unsigned int *bstline)
  166. {
  167. }
  168.  
  169. void
  170. help (void)
  171. {
  172.   ClrScreen ();
  173.   /*printz ("CHESS command summary\n");*/
  174.   printz (CP[40]);
  175.   printz ("----------------------------------------------------------------\n");
  176.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  177.   printz (CP[158]);
  178.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  179.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  180.   /*printz ("a7a8q     promote pawn to queen\n");*/
  181.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  182.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  183.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  184.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  185.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  186.   /*printz ("bd        redraw board            reverse   board display\n");*/
  187.   printz (CP[130]);
  188.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount, booksize);*/
  189.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  190.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  191.   printz (CP[200]);
  192.   /*printz ("edit      edit board              force     enter game moves\n");*/
  193.   printz (CP[153]);
  194.   /*printz ("switch    sides with computer     both      computer match\n");*/
  195.   printz (CP[194]);
  196.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  197.   printz (CP[202]);
  198.   /*printz ("depth     set search depth        clock     set time control\n");*/
  199.   printz (CP[149]);
  200.   /*printz ("hint      suggest a move         post      turn %s principle variation\n", (flag.post) ? "off" : "on");*/
  201.   printz (CP[177], (flag.post) ? CP[92] : CP[93]);
  202.   /*printz ("save      game to file            get       game from file\n");*/
  203.   printz (CP[188]);
  204.   /*printz ("random    randomize play          new       start new game\n");*/
  205.   printz (CP[181]);
  206.   /*printz ("coords    show coords            rv        reverse video\n");*/
  207.   printz (CP[144]);
  208. #if !defined(MSDOS) || defined(SEVENBIT)
  209.   printz (CP[192]);
  210. #endif /* !MSDOS || SEVENBIT */
  211.   gotoXY (10, 20);
  212.   printz (CP[47], ColorStr[computer]);
  213.   gotoXY (10, 21);
  214.   printz (CP[97], ColorStr[opponent]);
  215.   gotoXY (10, 22);
  216.   printz (CP[79], MaxResponseTime/100);
  217.   gotoXY (10, 23);
  218.   printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
  219.   gotoXY (40, 20);
  220.   printz (CP[52], MaxSearchDepth);
  221.   gotoXY (40, 21);
  222.   printz (CP[100], (dither) ? CP[93] : CP[92]);
  223.   gotoXY (40, 22);
  224.   printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
  225.   gotoXY (40, 23);
  226.   printz (CP[73]);
  227.   gotoXY (10, 24);
  228.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  229.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  230.   refresh ();
  231. #ifdef BOGUS
  232.   fflush (stdin); /*what is this supposed to do??*/
  233. #endif /*BOGUS*/
  234.   getchar ();
  235.   ClrScreen ();
  236.   UpdateDisplay (0, 0, 1, 0);
  237. }
  238.  
  239. void
  240. EditBoard (void)
  241.  
  242. /*
  243.  * Set up a board position. Pieces are entered by typing the piece followed
  244.  * by the location. For example, Nf3 will place a knight on square f3.
  245.  */
  246.  
  247. {
  248.   short a, r, c, sq, i;
  249.   char s[80];
  250.  
  251.   flag.regularstart = true;
  252.   Book = BOOKFAIL;
  253.   ClrScreen ();
  254.   UpdateDisplay (0, 0, 1, 0);
  255.   gotoXY (TAB, 3);
  256.   printz (CP[29]);
  257.   gotoXY (TAB, 4);
  258.   printz (CP[28]);
  259.   gotoXY (TAB, 5);
  260.   printz (CP[136]);
  261.   gotoXY (TAB, 7);
  262.   printz (CP[64]);
  263.   a = white;
  264.   do
  265.     {
  266.       gotoXY (TAB, 6);
  267.       printz (CP[60], ColorStr[a]);    /*Editing %s*/
  268.       gotoXY (TAB + 24, 7);
  269.       ClrEoln ();
  270.       scanz ("%s", s);
  271.       if (s[0] == CP[28][0])    /*#*/
  272.     {
  273.       for (sq = 0; sq < 64; sq++)
  274.         {
  275.           board[sq] = no_piece;
  276.           color[sq] = neutral;
  277.           DrawPiece (sq);
  278.         }
  279.     }
  280.       if (s[0] == CP[136][0])    /*c*/
  281.     a = otherside[a];
  282.       c = s[1] - 'a';
  283.       r = s[2] - '1';
  284.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  285.     {
  286.       sq = locn (r, c);
  287.       for (i = king; i > no_piece; i--)
  288.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  289.           break;
  290.       board[sq] = i;
  291.       color[sq] = ((board[sq] == no_piece) ? neutral : a);
  292.       DrawPiece (sq);
  293.     }
  294.   } while (s[0] != CP[29][0]);
  295.  
  296.   for (sq = 0; sq < 64; sq++)
  297.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  298.   GameCnt = 0;
  299.   Game50 = 1;
  300.   ZeroRPT ();
  301.   Sdepth = 0;
  302.   InitializeStats ();
  303.   ClrScreen ();
  304.   UpdateDisplay (0, 0, 1, 0);
  305. }
  306.  
  307. void
  308. ShowPlayers (void)
  309. {
  310.   gotoXY (TAB, ((flag.reverse) ? 23 : 2));
  311.   printz ("%s", (computer == black) ? CP[218] : CP[74]);
  312.   gotoXY (TAB, ((flag.reverse) ? 2 : 23));
  313.   printz ("%s", (computer == white) ? CP[218] : CP[74]);
  314. }
  315.  
  316. void
  317. ShowDepth (char ch)
  318. {
  319.   gotoXY (TAB, 4);
  320.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  321.   ClrEoln ();
  322. }
  323.  
  324. void
  325. ShowScore (short score)
  326. {
  327.   gotoXY (TAB, 5);
  328.  printz (CP[104], score);
  329.   ClrEoln ();
  330. }
  331.  
  332. void
  333. ShowMessage (char *s)
  334. {
  335.   gotoXY (TAB, 6);
  336.   printz ("%s", s);
  337.   ClrEoln ();
  338. }
  339.  
  340. void
  341. ClearMessage (void)
  342. {
  343.   gotoXY (TAB, 6);
  344.   ClrEoln ();
  345. }
  346.  
  347. void
  348. ShowCurrentMove (short int pnt, short int f, short int t)
  349. {
  350.   algbr (f, t, false);
  351.   gotoXY (TAB, 7);
  352.   printz ("(%2d) %4s", pnt, mvstr[0]);
  353. }
  354.  
  355. void
  356. ShowHeader (void)
  357. {
  358.   gotoXY (TAB, 10);
  359. #ifdef MSDOS
  360.   printz (CP[67]);
  361. #else
  362.   printz (CP[68]);
  363. #endif /* MSDOS */
  364. }
  365.  
  366. void
  367. ShowSidetoMove (void)
  368. {
  369.   gotoXY (TAB, 14);
  370.   printz ("%2d:   %s", 1 + GameCnt / 2, ColorStr[player]);
  371.   ClrEoln ();
  372. }
  373.  
  374. void
  375. ShowPrompt (void)
  376. {
  377.   gotoXY (TAB, 19);
  378.   printz (CP[121]);        /*Your movwe is?*/
  379.   ClrEoln ();
  380. }
  381.  
  382. void
  383. ShowNodeCnt (long int NodeCnt)
  384. {
  385.   gotoXY (TAB, 21);
  386.   printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
  387.   ClrEoln ();
  388. }
  389.  
  390. void
  391. ShowResults (short int score, short unsigned int *bstline, char ch)
  392. {
  393.   unsigned char d, ply;
  394.  
  395.   if (flag.post)
  396.     {
  397.       ShowDepth (ch);
  398.       ShowScore (score);
  399.       d = 7;
  400.       for (ply = 1; bstline[ply] > 0; ply++)
  401.     {
  402.       if (ply % 4 == 1)
  403.         {
  404.           gotoXY (TAB, ++d);
  405.           ClrEoln ();
  406.         }
  407.       algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
  408.       printz ("%5s ", mvstr[0]);
  409.     }
  410.       ClrEoln ();
  411.       while (d < 13)
  412.     {
  413.       gotoXY (TAB, ++d);
  414.       ClrEoln ();
  415.     }
  416.     }
  417. }
  418.  
  419. void
  420. SearchStartStuff (short int side)
  421. {
  422.   short i;
  423.  
  424.   signal (SIGINT, TerminateSearch);
  425. #ifdef MSDOS
  426.   side++;            /* shut up the compiler */
  427. #else
  428.   signal (SIGQUIT, TerminateSearch);
  429. #endif /* MSDOS */
  430.   for (i = 4; i < 14; i++)
  431.     {
  432.       gotoXY (TAB, i);
  433.       ClrEoln ();
  434.     }
  435. }
  436.  
  437. void
  438. OutputMove (void)
  439. {
  440.  
  441.   UpdateDisplay (root->f, root->t, 0, (short) root->flags);
  442.   gotoXY (TAB, 17);
  443.   if(flag.illegal) {printz (CP[225]); return;}
  444.   printz (CP[84], mvstr[0]);    /*My move is %s*/
  445.   if (flag.beep)
  446.     putchar (7);
  447.   ClrEoln ();
  448.  
  449.   gotoXY (TAB, 24);
  450.   if (root->flags & draw)
  451.     printz (CP[56], DRAW);
  452.   else if (root->score == -9999)
  453.     printz (CP[95]);
  454.   else if (root->score == 9998)
  455.     printz (CP[44]);
  456. #ifdef VERYBUGGY
  457.   else if (root->score < -9000)
  458.     printz (CP[96]);
  459.   else if (root->score > 9000)
  460.     printz (CP[45]);
  461. #endif /*VERYBUGGY*/
  462.   ClrEoln ();
  463.  
  464.   if (flag.post)
  465.     {
  466.       register short h, l, t;
  467.  
  468.       h = TREE;
  469.       l = 0;
  470.       t = TREE >> 1;
  471.       while (l != t)
  472.     {
  473.       if (Tree[t].f || Tree[t].t)
  474.         l = t;
  475.       else
  476.         h = t;
  477.       t = (l + h) >> 1;
  478.     }
  479.  
  480.  
  481.       ShowNodeCnt (NodeCnt);
  482.       gotoXY (TAB, 22);
  483.  
  484.       printz (CP[81], t);    /*Max Tree= %d*/
  485.       ClrEoln ();
  486.     }
  487. }
  488.  
  489. void
  490. UpdateClocks (void)
  491. {
  492.   short m, s;
  493.  
  494.   m = (short) (et / 6000);
  495.   s = (short) (et - 6000 * (long) m) / 100;
  496.   if (TCflag)
  497.     {
  498.       m = (short) ((TimeControl.clock[player] - et) / 6000);
  499.       s = (short) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  500.     }
  501.   if (m < 0)
  502.     m = 0;
  503.   if (s < 0)
  504.     s = 0;
  505.   if (player == white)
  506.     gotoXY (60, (flag.reverse) ? 2 : 23);
  507.   else
  508.     gotoXY (60, (flag.reverse) ? 23 : 2);
  509.   printz ("%d:%02d   ", m, s);
  510.   if (flag.post)
  511.     ShowNodeCnt (NodeCnt);
  512.   refresh ();
  513. }
  514.  
  515. void
  516. gotoXY (short int x, short int y)
  517. {
  518. #ifdef MSDOS
  519.   putchar (ESC);
  520.   putchar ('[');
  521.   param (y);
  522.   putchar (';');
  523.   param (x);
  524.   putchar ('H');
  525. #else
  526.   move (y - 1, x - 1);
  527. #endif /* MSDOS */
  528. }
  529.  
  530. void
  531. ClrScreen (void)
  532. {
  533. #ifdef MSDOS
  534.   putchar (ESC);
  535.   putchar ('[');
  536.   putchar ('2');
  537.   putchar ('J');
  538. #else
  539.   clear ();
  540. #endif /* MSDOS */
  541.   refresh ();
  542. }
  543.  
  544. void
  545. ClrEoln (void)
  546. {
  547. #ifdef MSDOS
  548.   putchar (ESC);
  549.   putchar ('[');
  550.   putchar ('K');
  551. #else
  552.   clrtoeol ();
  553. #endif /* MSDOS */
  554.   refresh ();
  555. }
  556.  
  557. #ifdef MSDOS
  558. void
  559. param (short n)
  560. {
  561.   if (n >= 10)
  562.     {
  563.       register short d, q;
  564.  
  565.       q = n / 10;
  566.       d = n % 10;
  567.       putchar (q + '0');
  568.       putchar (d + '0');
  569.     }
  570.   else
  571.     putchar (n + '0');
  572. }
  573.  
  574. #endif /* MSDOS */
  575.  
  576. void
  577. OReverse ()
  578. {
  579. #ifdef MSDOS
  580.   putchar (ESC);
  581.   putchar ('[');
  582.   param (7);
  583.   putchar ('m');
  584. #else
  585.   standout ();
  586.   /* attron (A_REVERSE); */
  587. #endif /* MSDOS */
  588. }
  589.  
  590. void
  591. ONormal ()
  592. {
  593. #ifdef MSDOS
  594.   putchar (ESC);
  595.   putchar ('[');
  596.   param (0);
  597.   putchar ('m');
  598. #else
  599.   standend ();
  600.   /* attroff (A_REVERSE); */
  601. #endif /* MSDOS */
  602. }
  603.  
  604. void
  605. DrawPiece (short int sq)
  606. {
  607.   gotoXY (VcoordR (sq, 2, 2));
  608.  
  609.   switch (color[sq])
  610.     {
  611.     case black:
  612.       if (flag.rv)
  613.     OReverse ();
  614. #if defined(MSDOS) && !defined(SEVENBIT)
  615.       printz (" %c ", pxx[board[sq]]);
  616. #else
  617.       printz ((flag.stars ? "*%c*" : " %c "), pxx[board[sq]]);
  618. #endif /* MSDOS && !SEVENBIT */
  619.       ONormal ();
  620.       break;
  621.     case neutral:
  622. #if defined(MSDOS) && !defined(SEVENBIT)
  623.       if (flag.rv)
  624.     printz (Vblack (sq) ? "\262\262\262" : "\260\260\260");
  625.       else
  626.     printz (Vblack (sq) ? "\260\260\260" : "\262\262\262");
  627. #else
  628.       if (flag.shade)
  629.     printz (Vblack (sq) ? "///" : "   ");
  630.       else
  631.     {
  632.       if (Vblack (sq))
  633.         OReverse ();
  634.       printz ("   ");
  635.       ONormal ();
  636.     }
  637. #endif /* MSDOS && !SEVENBIT */
  638.       break;
  639.     case white:
  640. #if defined(MSDOS) && !defined(SEVENBIT)
  641.       if (!flag.rv)
  642.     OReverse ();
  643.       printz (" %c ", pxx[board[sq]]);
  644.       ONormal ();
  645. #else
  646.       printz (" %c ", pxx[board[sq]]);
  647. #endif /* MSDOS && !SEVENBIT */
  648.       break;
  649.     default:
  650.       ShowMessage (CP[55]);    /*Draw piece color[sq] err*/
  651.       break;
  652.     }
  653. }
  654.  
  655. void
  656. DrawSquare (short int sq)
  657. {
  658. #if defined(MSDOS) && !defined(SEVENBIT)
  659.   if (flag.rv)
  660.     {
  661.       gotoXY (Vcoord (sq, 1, 1));
  662.       printz (Vblack (sq) ? "\262\262\262\262\262" : "\260\260\260\260\260");
  663.       gotoXY (Vcoord (sq, 1, 2));
  664.       printz (Vblack (sq) ? "\262\262\262\262\262" : "\260\260\260\260\260");
  665.       gotoXY (Vcoord (sq, 1, 3));
  666.       printz (Vblack (sq) ? "\262\262\262\262\262" : "\260\260\260\260\260");
  667.     }
  668.   else
  669.     {
  670.       gotoXY (Vcoord (sq, 1, 1));
  671.       printz (Vblack (sq) ? "\260\260\260\260\260" : "\262\262\262\262\262");
  672.       gotoXY (Vcoord (sq, 1, 2));
  673.       printz (Vblack (sq) ? "\260\260\260\260\260" : "\262\262\262\262\262");
  674.       gotoXY (Vcoord (sq, 1, 3));
  675.       printz (Vblack (sq) ? "\260\260\260\260\260" : "\262\262\262\262\262");
  676.     }
  677. #else
  678.   if (flag.shade)
  679.     {
  680.       gotoXY (Vcoord (sq, 1, 1));
  681.       printz (Vblack (sq) ? "/////" : "     ");
  682.       gotoXY (Vcoord (sq, 1, 2));
  683.       printz (Vblack (sq) ? "/////" : "     ");
  684.       gotoXY (Vcoord (sq, 1, 3));
  685.       printz (Vblack (sq) ? "/////" : "     ");
  686.     }
  687.   else
  688.     {
  689.       if (Vblack (sq))
  690.     OReverse ();
  691.       gotoXY (Vcoord (sq, 1, 1));
  692.       printz ("     ");
  693.       gotoXY (Vcoord (sq, 1, 2));
  694.       printz ("     ");
  695.       gotoXY (Vcoord (sq, 1, 3));
  696.       printz ("     ");
  697.       ONormal ();
  698.     }
  699. #endif /* MSDOS && !SEVENBIT */
  700. }
  701.  
  702. void
  703. DrawCoords (void)
  704. {
  705.   short z;
  706.  
  707.   for (z = 0; z <= 7; z++)
  708.     {
  709.       short sq;
  710.  
  711.       sq = z << 3;
  712.       gotoXY (VcoordI (sq, 1, 1));
  713. #if !defined(MSDOS) || defined(SEVENBIT)
  714.       if ((Vblack (sq) || flag.shade) && flag.rv)
  715. #endif /* !MSDOS || SEVENBIT */
  716.     OReverse ();
  717.       printz ("%d", 1 + z);
  718.       ONormal ();
  719.     }
  720.  
  721.   for (z = 0; z <= 7; z++)
  722.     {
  723.       short sq;
  724.  
  725.       sq = z;
  726.       gotoXY (VcoordI (sq, SQW, SQH));
  727. #if !defined(MSDOS) || defined(SEVENBIT)
  728.       if ((Vblack (sq) || flag.shade) && flag.rv)
  729. #endif /* !MSDOS || SEVENBIT */
  730.     OReverse ();
  731.       printz ("%c", cxx[z]);
  732.       ONormal ();
  733.     }
  734.  
  735. #if !defined(MSDOS) || defined(SEVENBIT)
  736.   for (z = 1; z <= (8 * SQH); z++)
  737.     {
  738.       gotoXY ((8 * SQW) + 1, z);
  739.       printz ("|");
  740.     }
  741. #endif /* MSDOS && !SEVENBIT */
  742. }
  743.  
  744. void
  745. ShowPostnValue (short int sq)
  746.  
  747. /*
  748.  * must have called ExaminePosition() first
  749.  */
  750.  
  751. {
  752.   short score;
  753.  
  754.   gotoXY (VcoordR (sq, 2, 1));
  755.   score = ScorePosition (color[sq]);
  756. #if !defined(MSDOS) || defined(SEVENBIT)
  757.   if (Vblack (sq) && !flag.shade)
  758.     OReverse ();
  759. #endif /* !MSDOS || SEVENBIT */
  760.  
  761.   if (color[sq] != neutral)
  762.     printz ("%3d", svalue[sq]);
  763.   else
  764. #if defined(MSDOS) && !defined(SEVENBIT)
  765.     {
  766.       if (flag.rv)
  767.     printz (Vblack (sq) ? "\262\262\262" : "\260\260\260");
  768.       else
  769.     printz (Vblack (sq) ? "\260\260\260" : "\262\262\262");
  770.     }
  771. #else
  772.     printz (flag.shade && Vblack (sq) ? "///" : "   ");
  773. #endif /* MSDOS && !SEVENBIT */
  774.   ONormal ();
  775. }
  776.  
  777. void
  778. ShowPostnValues (void)
  779. {
  780.   short sq, score;
  781.  
  782.   ExaminePosition ();
  783.   for (sq = 0; sq < 64; sq++)
  784.     ShowPostnValue (sq);
  785.   score = ScorePosition (opponent);
  786.   gotoXY (TAB, 5);
  787.  printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  788.   ClrEoln ();
  789. }
  790.  
  791. void
  792. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  793. {
  794.   short sq;
  795.  
  796.   if (redraw)
  797.     {
  798.       ShowHeader ();
  799.       ShowPlayers ();
  800.       for (sq = 0; sq < 64; sq++)
  801.     {
  802.       DrawSquare (sq);
  803.       DrawPiece (sq);
  804.     }
  805.       if (flag.coords)
  806.     DrawCoords ();
  807.     }
  808.   else
  809.     {
  810.       DrawPiece (f);
  811.       DrawPiece (t);
  812.       if (isspec & cstlmask)
  813.     if (t > f)
  814.       {
  815.         DrawPiece (f + 3);
  816.         DrawPiece (t - 1);
  817.       }
  818.     else
  819.       {
  820.         DrawPiece (f - 4);
  821.         DrawPiece (t + 1);
  822.       }
  823.       else if (isspec & epmask)
  824.     {
  825.       DrawPiece (t - 8);
  826.       DrawPiece (t + 8);
  827.     }
  828.     }
  829.   if (PositionFlag)
  830.     ShowPostnValues ();
  831.   refresh ();
  832. }
  833.  
  834. extern char *InPtr;
  835. void
  836. skip ()
  837. {
  838.   while (*InPtr != ' ')
  839.     InPtr++;
  840.   while (*InPtr == ' ')
  841.     InPtr++;
  842. }
  843. void
  844. skipb ()
  845. {
  846.   while (*InPtr == ' ')
  847.     InPtr++;
  848. }
  849.  
  850. void
  851. ChangeAlphaWindow (void)
  852. {
  853.   ShowMessage (CP[114]);
  854.   scanz ("%hd", &WAwindow);
  855.   ShowMessage (CP[34]);
  856.   scanz ("%hd", &BAwindow);
  857. }
  858.  
  859. void
  860. ChangeBetaWindow (void)
  861. {
  862.   ShowMessage (CP[115]);
  863.   scanz ("%hd", &WBwindow);
  864.   ShowMessage (CP[35]);
  865.   scanz ("%hd", &BBwindow);
  866. }
  867.  
  868. void
  869. GiveHint (void)
  870. {
  871.   char s[40];
  872.   if (hint)
  873.     {
  874.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  875.       strcpy (s, CP[198]);    /*try*/
  876.       strcat (s, mvstr[0]);
  877.       ShowMessage (s);
  878.     }
  879.   else
  880.     ShowMessage (CP[223]);
  881. }
  882.  
  883. void
  884. ChangeHashDepth (void)
  885. {
  886.   ShowMessage (CP[163]);
  887.   scanz ("%hd", &HashDepth);
  888.   ShowMessage (CP[82]);
  889.   scanz ("%hd", &HashMoveLimit);
  890. }
  891.  
  892. void
  893. ChangeSearchDepth (void)
  894. {
  895.   ShowMessage (CP[150]);
  896.   scanz ("%hd", &MaxSearchDepth);
  897.   TCflag = !(MaxSearchDepth > 0);
  898. }
  899.  
  900. void
  901. SetContempt (void)
  902. {
  903.   ShowMessage (CP[142]);
  904.   scanz ("%hd", &contempt);
  905. }
  906.  
  907.  
  908. void
  909. SetAnalysis (void)
  910. {
  911.   ShowMessage (CP[159]);
  912.   scanz ("%s", Analysis);
  913. }
  914.  
  915. void
  916. ChangeXwindow (void)
  917. {
  918.   ShowMessage (CP[208]);
  919.   scanz ("%hd", &xwndw);
  920. }
  921.  
  922. void
  923. SelectLevel (char *sx)
  924. {
  925.   int item;
  926.  
  927.   ClrScreen ();
  928.   gotoXY (32, 2);
  929.   printz (CP[41]);
  930.   gotoXY (20, 4);
  931.   printz (CP[18]);
  932.   gotoXY (20, 5);
  933.   printz (CP[19]);
  934.   gotoXY (20, 6);
  935.   printz (CP[20]);
  936.   gotoXY (20, 7);
  937.   printz (CP[21]);
  938.   gotoXY (20, 8);
  939.   printz (CP[22]);
  940.   gotoXY (20, 9);
  941.   printz (CP[23]);
  942.   gotoXY (20, 10);
  943.   printz (CP[24]);
  944.   gotoXY (20, 11);
  945.   printz (CP[25]);
  946.   gotoXY (20, 12);
  947.   printz (CP[26]);
  948.   gotoXY (20, 13);
  949.   printz (CP[27]);
  950.  
  951.   OperatorTime = 0;
  952.   TCmoves = 60;
  953.   TCminutes = 5;
  954.   TCseconds = 0;
  955.   gotoXY (20, 17);
  956.   printz (CP[62]);
  957.   refresh ();
  958.   scanz ("%d", &item);
  959.   switch (item)
  960.     {
  961.     case 1:
  962.       TCmoves = 60;
  963.       TCminutes = 5;
  964.       break;
  965.     case 2:
  966.       TCmoves = 60;
  967.       TCminutes = 15;
  968.       break;
  969.     case 3:
  970.       TCmoves = 60;
  971.       TCminutes = 30;
  972.       break;
  973.     case 4:
  974.       TCmoves = 40;
  975.       TCminutes = 30;
  976.       break;
  977.     case 5:
  978.       TCmoves = 40;
  979.       TCminutes = 60;
  980.       break;
  981.     case 6:
  982.       TCmoves = 40;
  983.       TCminutes = 120;
  984.       break;
  985.     case 7:
  986.       TCmoves = 40;
  987.       TCminutes = 240;
  988.       break;
  989.     case 8:
  990.       TCmoves = 1;
  991.       TCminutes = 15;
  992.       break;
  993.     case 9:
  994.       TCmoves = 1;
  995.       TCminutes = 60;
  996.       break;
  997.     case 10:
  998.       TCmoves = 1;
  999.       TCminutes = 600;
  1000.       break;
  1001.     }
  1002.  
  1003.   TCflag = (TCmoves > 0);
  1004.  
  1005.   TimeControl.clock[white] = TimeControl.clock[black] = 0; 
  1006.  
  1007.   SetTimeControl ();
  1008.   ClrScreen ();
  1009.   UpdateDisplay (0, 0, 1, 0);
  1010. }
  1011.  
  1012. void
  1013. DoDebug (void)
  1014. {
  1015.   short c, p, sq, tp, tc, tsq, score;
  1016.   char s[40];
  1017.  
  1018.   ExaminePosition ();
  1019.   ShowMessage (CP[65]);
  1020.   scanz ("%s", s);
  1021.   c = neutral;
  1022.   if (s[0] == CP[9][0] || s[0] == CP[9][1])    /* w W*/ c = white;
  1023.   if (s[0] == CP[9][2] || s[0] == CP[9][3])    /*b B*/ c = black;
  1024.   for (p = king; p > no_piece; p--)
  1025.     if ((s[1] == pxx[p]) || (s[1] == qxx[p])) break;
  1026.   if(p > no_piece)
  1027.   for (sq = 0; sq < 64; sq++)
  1028.     {
  1029.       tp = board[sq];
  1030.       tc = color[sq];
  1031.       board[sq] = p;
  1032.       color[sq] = c;
  1033.       tsq = PieceList[c][1];
  1034.       PieceList[c][1] = sq;
  1035.       ShowPostnValue (sq);
  1036.       PieceList[c][1] = tsq;
  1037.       board[sq] = tp;
  1038.       color[sq] = tc;
  1039.     }
  1040.   score = ScorePosition (opponent);
  1041.   gotoXY (TAB, 5);
  1042.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  1043.   ClrEoln ();
  1044. }
  1045. void
  1046. DoTable (short table[64])
  1047. {
  1048.   short  sq;
  1049.   ExaminePosition ();
  1050.   for (sq=0;sq<64;sq++){
  1051.  
  1052.   gotoXY (VcoordR (sq, 2, 1));
  1053. #if !defined(MSDOS) || defined(SEVENBIT)
  1054.   if (Vblack (sq) && !flag.shade)
  1055.     OReverse ();
  1056. #endif /* !MSDOS || SEVENBIT */
  1057.  
  1058.     printz ("%3d", table[sq]);
  1059.   ONormal ();
  1060. }
  1061. }
  1062.  
  1063.